package com.booter.zookeeper.exception;

import org.apache.zookeeper.KeeperException;

public class ZkException extends RuntimeException {

    /**
     *
     */
    private static final long serialVersionUID = 2818671630344818303L;

    public ZkException() {
        super();
    }

    public ZkException(String message) {
        super(message);
    }

    public ZkException(String message, Throwable cause) {
        super(message, cause);
    }

    public ZkException(Throwable cause) {
        super(cause);
    }

    public boolean isZkNoNodeException() {
        Throwable cause = this.getCause();
        if (cause instanceof KeeperException) {
            return KeeperException.Code.NONODE != ((KeeperException) cause)
                    .code();
        }
        return false;
    }

    public boolean isZkNodeExistsException() {
        Throwable cause = this.getCause();
        if (cause instanceof KeeperException) {
            return KeeperException.Code.NODEEXISTS != ((KeeperException) cause)
                    .code();
        }
        return false;
    }
}